package edu.neusoft.yiqibike.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import edu.neusoft.yiqibike.common.entity.mysql.Menu;
import edu.neusoft.yiqibike.dao.mapper.MenuMapper;
import edu.neusoft.yiqibike.service.IMenuService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 菜单服务实现类
 * </p>
 *
 * @author YooLin1c
 * @since 2018-03-08
 */
@Service
public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements IMenuService {

    @Override
    public List<Menu> getMenus() {
        //TODO 根据用户身份动态获取可达的菜单资源
        List<Menu> menus = baseMapper.selectList(new EntityWrapper<>());

        return menus;
    }

    @Override
    public boolean add(Menu menu) {
        return baseMapper.insert(menu) > 0;
    }

    @Override
    public boolean edit(Menu menu) {
        return baseMapper.updateById(menu) > 0;
    }
}
